cmake_minimum_required(VERSION 3.10)
project(CollaborativeDesignPlugin VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# 查找Qt包
find_package(Qt5 COMPONENTS Core Widgets Network WebSockets REQUIRED)

# 设置自动生成MOC文件
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 添加FastCAE的包含目录（需要根据实际情况调整）
set(FASTCAE_INCLUDE_DIR "$ENV{FASTCAE_ROOT}/include")
include_directories(${FASTCAE_INCLUDE_DIR})

# 添加FastCAE的库目录（需要根据实际情况调整）
set(FASTCAE_LIB_DIR "$ENV{FASTCAE_ROOT}/lib")
link_directories(${FASTCAE_LIB_DIR})

# 源文件
set(SOURCES
    CollaborativeDesignPlugin.cpp
    VersionControl.cpp
    CollaborationManager.cpp
    SyncManager.cpp
    PermissionManager.cpp
)

# 头文件
set(HEADERS
    CollaborativeDesignPlugin.h
    VersionControl.h
    CollaborationManager.h
    SyncManager.h
    PermissionManager.h
)

# 资源文件
set(RESOURCES
    resources.qrc
)

# 添加库目标
add_library(${PROJECT_NAME} SHARED
    ${SOURCES}
    ${HEADERS}
    ${RESOURCES}
)

# 设置目标属性
set_target_properties(${PROJECT_NAME} PROPERTIES
    PREFIX ""
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins"
)

# 链接Qt库
target_link_libraries(${PROJECT_NAME} PRIVATE
    Qt5::Core
    Qt5::Widgets
    Qt5::Network
    Qt5::WebSockets
)

# 链接FastCAE库（需要根据实际情况调整）
target_link_libraries(${PROJECT_NAME} PRIVATE
    FITKAppFramework
)

# 安装目标
install(TARGETS ${PROJECT_NAME}
    LIBRARY DESTINATION plugins
    RUNTIME DESTINATION plugins
)

# 添加测试（可选）
option(BUILD_TESTS "Build tests" OFF)
if(BUILD_TESTS)
    enable_testing()
    add_subdirectory(tests)
endif()

# 添加示例（可选）
option(BUILD_EXAMPLES "Build examples" OFF)
if(BUILD_EXAMPLES)
    add_subdirectory(examples)
endif()

# 输出配置信息
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "Qt5 version: ${Qt5_VERSION}")
message(STATUS "FastCAE include dir: ${FASTCAE_INCLUDE_DIR}")
message(STATUS "FastCAE lib dir: ${FASTCAE_LIB_DIR}") 